package com.hungtrung.entity;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.math.Vector2;
import com.hungtrung.game.GameConfig;
import com.hungtrung.game.TextureManager;

public class Ro extends Entity{
	MyInputProcessor mip = new MyInputProcessor();
	public Ro(Vector2 pos, Vector2 direction) {
		super(TextureManager.RO, pos, direction);
	}

	@Override
	public void update() {					
		if(Gdx.input.isKeyPressed(Keys.LEFT) && pos.x>0){		
			pos.add(direction);
			setPosition(-300, 0);			
		}
		if(Gdx.input.isKeyPressed(Keys.RIGHT)  && pos.x<=GameConfig.WIDTH - this.texture.getWidth()){
			pos.add(direction);
			setPosition(300, 0);
		}
		Gdx.input.setInputProcessor(mip);//mouse, android touch		
	}
	
	
	class MyInputProcessor implements InputProcessor{
		
		@Override
		public boolean keyDown(int keycode) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean keyUp(int keycode) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean keyTyped(char character) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean touchDown(int screenX, int screenY, int pointer, int button) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean touchUp(int screenX, int screenY, int pointer, int button) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean touchDragged(int screenX, int screenY, int pointer) {
			// TODO Auto-generated method stub
			if(screenX<=GameConfig.WIDTH - 100 && screenX>0){
				pos.x = screenX;
				pos.add(direction);
				setPosition(-300, 0);				
			}
			return false;
		}

		@Override
		public boolean mouseMoved(int screenX, int screenY) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean scrolled(int amount) {
			// TODO Auto-generated method stub
			return false;
		}
	}
	
}
